sed -i "s@http://.*archive.ubuntu.com@http://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list && \
    sed -i "s@http://.*security.ubuntu.com@http://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list && \
    apt-get update && apt-get install -y --no-install-recommends \
        wget curl gnupg2 lsb-release software-properties-common ca-certificates tmux \
        openssl p7zip-full lrzsz unzip zip vim make gcc htop git git-lfs bc libopenmpi-dev nvidia-driver-550

export PATH=$HOME/opt/miniconda3/bin:${PATH}

# update /etc/resolv.conf

wget https://repo.anaconda.com/miniconda/Miniconda3-py312_24.9.2-0-Linux-x86_64.sh -O miniconda.sh && \
    mkdir -p $HOME/.conda && \
    bash miniconda.sh -b -p $HOME/opt/miniconda3 && \
    conda init

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
    dpkg -i cuda-keyring_1.1-1_all.deb && \
    apt-get update && \
    apt-get -y install --no-install-recommends cuda-toolkit-12-4 libnccl2 libnccl-dev && \
    rm -f cuda-keyring_1.1-1_all.deb

export PATH=/usr/local/cuda-12.4/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:${LD_LIBRARY_PATH}

pip install "nougat-ocr[api]"
cd fastchat
pip install -e ".[model_worker]"
cd ..
pip install flask albumentations==1.4.24 transformers==4.38.2

# Optional for sock5 proxy
pip install pysocks

# For app only
pip install flask flask_cors frontend aiohttp tools

pip install --upgrade --force-reinstall PyMuPDF

# refer to if required: https://github.com/facebookresearch/nougat/issues/57 
